import { Component } from "react";
import { Provider } from "mobx-react";
import Taro from '@tarojs/taro';
import {requestLogin} from './utils/api';
import goodStore from "./store/good";

import "./app.scss";

const store = {
  goodStore,
};

class App extends Component {
  componentDidMount() {
    console.log(1111);
    Taro.login({
      success(res){
        console.log(res);
        if(res.code){
          requestLogin({code:res.code}).then(res=>{
            console.log(res);
            Taro.setStorage({
              key:'token',
              data:res.data.token
            })
          })
        }else{
          console.log('登陆失败'+res.errMsg);
        }
      }})
      
      // Taro.getUserInfo({
      //   success(res){
      //     console.log(res);
      //   }
      // })
  }

  componentDidShow() {}

  componentDidHide() {}

  componentDidCatchError() {}

  // this.props.children 就是要渲染的页面
  render() {
    return <Provider store={store}>{this.props.children}</Provider>;
  }
}

export default App;
